<?php

namespace app\admin\controller;

use think\Controller;
use think\Request;

class Common extends Controller
{

    public function __construct(Request $request = null)
    {
        parent::__construct($request);

        if (!session('admin.admin_username')){
            return $this->redirect('login/login');
        }
    }

    public function getTree($list,$pid)
    {
        $tree = array();
        foreach($list as $k => $v)
        {
            if($v['cate_pid'] == $pid)
            {         //父亲找到儿子
                $v['child'] = $this->getTree($list, $v['cate_id']);
                $tree[] = $v;
            }
        }
        return $tree;
    }
    public function http_url(){

        return  input('server.REQUEST_SCHEME') . '://' . input('server.SERVER_NAME');

    }



}
